<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/template.xhtml">

<ui:define name="body">

<a:loadScript src="js/sw-util.js" />
<a:loadScript src="js/jquery.maskedinput-1.3.js" />
<a:loadScript src="js/jquery.maskedinput-1.1.4.pack.js" />

    <h:form id="PesquisaClienteForm">

        <rich:panel>
            <f:facet name="header">Consulta Cliente PJ</f:facet>
          
            
            <s:decorate id="cnpjField" template="layout/edit.xhtml">
                <ui:define name="label">CNPJ</ui:define>
                <h:inputText id="cnpj" required="false"
                             value="#{ClientePJBean.cnpj}"  maxlength="21" size="21" >
                             <rich:jQuery selector="#cnpj" query="mask('99.999.999/9999-99')" timing="onload"></rich:jQuery>
                </h:inputText>
            </s:decorate>            
            
            <s:decorate id="razaoSocialField" template="/layout/edit.xhtml">
                <ui:define name="label">Razao Social</ui:define>
                <h:inputText id="razaoSocialFieldId" value="#{ClientePJBean.razaoSocial}" size="100">
                </h:inputText>
            </s:decorate>

            <div style="clear:both"/>

	        <div class="actionButtons">
	            <a:commandButton id="btPesquisaCliente" value="Consultar"
	                    action="#{ClientePJBean.pesquisaCliente()}"  reRender="painelResultado"/>
	        </div>

        </rich:panel>
                

		    <rich:panel id="painelResultado">
		        <f:facet name="header">Listagem de Clientes</f:facet>
		        
		        <div class="results">
		
		            <h:outputText value="Nenhum cliente listado"
		                      rendered="#{empty ClientePJBean.clientesPJ}" />
							
						<rich:dataTable id="clientesPJSelecionadosList" value="#{ClientePJBean.clientesPJ}"
							var="_clientesPJSelecionado" rendered="#{not empty ClientePJBean.clientesPJ}" >

							<h:column>
								<f:facet name="header">Razao Social</f:facet>
		                    	#{_clientesPJSelecionado.razaoSocial}
							</h:column>
							
							<h:column styleClass="center-text">
								<f:facet name="header">CNPJ</f:facet>
		                    	#{_clientesPJSelecionado.cnpj}
							</h:column>
							
			                <h:column styleClass="center-text">
			                    <f:facet name="header">Acao</f:facet>
			                    <s:link id="editarCliente"
			                         value="Editar"
									action="#{ClientePJBean.editar}" 
									view="/clientePJ.xhtml" 
									propagation="join" >
									<f:param name="idCliente" value="#{_clientesPJSelecionado.id}" />
								</s:link>
						                                
			                </h:column>							
							

		            </rich:dataTable>
		        </div>

		    </rich:panel>
		    


        <div class="actionButtons">
        </div>
    </h:form>

</ui:define>

</ui:composition>
